#define _CRT_SECURE_NO_WARNINGS
#include<unordered_map>
#include<string>
#include<iostream>
using namespace std;
class Solution {
public:
    string minWindow(string s, string t) {
        int len = INT_MAX, pos = -1;
        int kinds = 0;
        unordered_map<char, int> mp;
        for (auto e : t)
        {
            if ((mp[e]++) == 0) kinds++;

        }
        unordered_map<char, int> mp1;
        for (int left = 0, right = 0, count = 0; right < s.size(); right++)
        {
            mp1[s[right]]++;
            if (mp1[s[right]] == mp[s[right]]) count++;
            while (kinds == count)
            {
                if (right - left + 1 < len)
                {
                    len = right - left + 1;
                    pos = left;
                }


                char out = s[left++];
                if (mp1[out]-- == mp[out])count--;


            }
        }
        return pos == -1 ? "" : s.substr(pos, len);
    }
};
int main()
{
    minWindow("ADOBECODEBANC", "ABC");
    return 0;
}